# -*- encoding:utf-8 -*-

from __future__ import unicode_literals

from django.db import models
from datetime import datetime
from django.contrib.auth.models import User
# Create your models here.
def user_directory_path(instance, filename):
    # file will be uploaded to MEDIA_ROOT/user_<id>/<filename>
    return 'user/{0}/{1}{2}'.format(instance.owner.username,datetime.now().strftime('%Y%m%d%H%M%S'), filename)

class MobliePage(models.Model):
    title=models.CharField(u'标题',max_length=1000,blank=True)
    title_img=models.ImageField(verbose_name=u'icon图标(150X100)',upload_to=user_directory_path,blank=True)
    short_dsp=models.TextField(u'简短描述',blank=True)
    long_dsp=models.TextField(u'详细描述',blank=True)
    owner=models.ForeignKey(User,verbose_name=u'拥有者',blank=True,null=True)
    
    class Meta:
        verbose_name =u'商品页面'
        verbose_name_plural =u'商品'


